﻿
namespace NetROS.Tiers.Windows.Forms
{
	/// <summary>
	/// This is the abstract edit form for the <see cref="Entities.RabatSpec"/> entity.
	/// </summary>
	/// <remarks>This class is overwritten by .netTiers at each generation.</remarks>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class RabatSpecEditControlBase : System.Windows.Forms.UserControl
	{
		#region Fields
		
		//private System.Windows.Forms.TableLayoutPanel uxTableLayoutPanel;
		/// <summary>
		/// The ErrorProvider for the Entity;
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxErrorProvider;
		
		/// <summary>
		/// The BindingSource for the entity.
		///</summary>
		protected System.Windows.Forms.BindingSource uxBindingSource;
						
		
		/// <summary>
		/// TextBox for the ID property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxID;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the ID property.
		/// </summary>
		protected System.Windows.Forms.Label uxIDLabel;
		
		/// <summary>
		/// ComboBox for the IDRabat property.
		/// </summary>
		protected System.Windows.Forms.ComboBox uxIDRabat;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the IDRabat property.
		/// </summary>
		protected System.Windows.Forms.Label uxIDRabatLabel;
		
		/// <summary>
		/// ComboBox for the IDSpec property.
		/// </summary>
		protected System.Windows.Forms.ComboBox uxIDSpec;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the IDSpec property.
		/// </summary>
		protected System.Windows.Forms.Label uxIDSpecLabel;
		
		/// <summary>
		/// TextBox for the Vrijed property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxVrijed;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the Vrijed property.
		/// </summary>
		protected System.Windows.Forms.Label uxVrijedLabel;
		#endregion
		
		#region Main entity
		private Entities.RabatSpec _RabatSpec;
		/// <summary>
		/// Gets or sets the <see cref="Entities.RabatSpec"/> entity to edit with this form.
		/// </summary>
		/// <value>The <see cref="Entities.RabatSpec"/> instance.</value>
		public Entities.RabatSpec RabatSpec
		{
			get {return this._RabatSpec;}
			set
			{
				this._RabatSpec = value;
				if (value != null) 
				{
					this.uxBindingSource.DataSource = value;
					BindControls();
				}			
				
			}
		}
		#endregion
		
		/// <summary>
		/// Binds the controls.
		/// </summary>
		private void BindControls()
		{
			this.uxID.DataBindings.Clear();
			this.uxID.DataBindings.Add("Text", this.uxBindingSource, "ID", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxIDRabat.DataBindings.Clear();
			this.uxIDRabat.DataBindings.Add("SelectedValue", this.uxBindingSource, "IDRabat", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxIDSpec.DataBindings.Clear();
			this.uxIDSpec.DataBindings.Add("SelectedValue", this.uxBindingSource, "IDSpec", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxVrijed.DataBindings.Clear();
			this.uxVrijed.DataBindings.Add("Text", this.uxBindingSource, "Vrijed", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
		}					
		
		#region Constructor
		
		/// <summary>
		/// Initializes a new instance of the <see cref="RabatSpecEditControlBase"/> class.
		/// </summary>
		public RabatSpecEditControlBase()
		{
			InitializeComponent();			
			
			this.uxBindingSource.CurrentItemChanged += new System.EventHandler(uxBindingSource_currentItemChanged);
		}		
		
		/// <summary>
		/// 
		/// </summary>
		private void uxBindingSource_currentItemChanged(object sender, System.EventArgs e)
		{
			if (_RabatSpec != null) _RabatSpec.Validate();
		}	
				
		/// <summary>
		/// Initializes the component.
		/// </summary>
		public void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.uxErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxBindingSource = new System.Windows.Forms.BindingSource(this.components);
			
			//this.uxTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
			this.uxID = new System.Windows.Forms.TextBox();
			uxIDLabel = new System.Windows.Forms.Label();
			this.uxIDRabat = new System.Windows.Forms.ComboBox();
			uxIDRabatLabel = new System.Windows.Forms.Label();
			this.uxIDSpec = new System.Windows.Forms.ComboBox();
			uxIDSpecLabel = new System.Windows.Forms.Label();
			this.uxVrijed = new System.Windows.Forms.TextBox();
			uxVrijedLabel = new System.Windows.Forms.Label();
			
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).BeginInit();
			this.SuspendLayout();
			
			// 
			// uxTableLayoutPanel
			// 
			//this.uxTableLayoutPanel.AutoSize = true;
			//this.uxTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
			//this.uxTableLayoutPanel.ColumnCount = 2;
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F));
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 250F));
			//this.uxTableLayoutPanel.Location = new System.Drawing.System.Drawing.Point(3, 3);
			//this.uxTableLayoutPanel.Name = "uxTableLayoutPanel";
			//this.uxTableLayoutPanel.RowCount = 2;
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.Size = new System.Drawing.Size(450, 50);
			//this.uxTableLayoutPanel.TabIndex = 0;
			
			//
			// uxErrorProvider
			//
			this.uxErrorProvider.ContainerControl = this;
			this.uxErrorProvider.DataSource = this.uxBindingSource;
			
			//
			// uxIDLabel
			//
			this.uxIDLabel.Text = "ID:";
			this.uxIDLabel.Location = new System.Drawing.Point(3, 0);
			this.Controls.Add(this.uxIDLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDLabel);			
			//
			// uxID
			//
			this.uxID.ReadOnly = true;
			//this.uxTableLayoutPanel.Controls.Add(this.uxID);
			this.uxID.Location = new System.Drawing.Point(160, 0);
			this.Controls.Add(this.uxID);
			//
			// uxIDRabatLabel
			//
			this.uxIDRabatLabel.Text = "IDRabat:";
			this.uxIDRabatLabel.Location = new System.Drawing.Point(3, 26);
			this.Controls.Add(this.uxIDRabatLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDRabatLabel);			
			//
			// uxIDRabat
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDRabat);
			this.uxIDRabat.Location = new System.Drawing.Point(160, 26);
			this.Controls.Add(this.uxIDRabat);
			//
			// uxIDSpecLabel
			//
			this.uxIDSpecLabel.Text = "IDSpec:";
			this.uxIDSpecLabel.Location = new System.Drawing.Point(3, 52);
			this.Controls.Add(this.uxIDSpecLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDSpecLabel);			
			//
			// uxIDSpec
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxIDSpec);
			this.uxIDSpec.Location = new System.Drawing.Point(160, 52);
			this.Controls.Add(this.uxIDSpec);
			//
			// uxVrijedLabel
			//
			this.uxVrijedLabel.Text = "Vrijed:";
			this.uxVrijedLabel.Location = new System.Drawing.Point(3, 78);
			this.Controls.Add(this.uxVrijedLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxVrijedLabel);			
			//
			// uxVrijed
			//
			this.uxVrijed.Width = 250;
			this.uxVrijed.MaxLength = 500;
			//this.uxTableLayoutPanel.Controls.Add(this.uxVrijed);
			this.uxVrijed.Location = new System.Drawing.Point(160, 78);
			this.Controls.Add(this.uxVrijed);
			//
			// uxIDSpec
			//				
			this.uxIDSpec.DisplayMember = "Naziv";	
			this.uxIDSpec.ValueMember = "ID";	
			//
			// uxIDRabat
			//				
			this.uxIDRabat.DisplayMember = "IDKlijent";	
			this.uxIDRabat.ValueMember = "ID";	
			// 
			// RabatSpecEditControlBase
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			//this.Controls.Add(this.uxTableLayoutPanel);
			this.AutoScroll = true;
			this.Name = "RabatSpecEditControlBase";
			this.Size = new System.Drawing.Size(478, 311);
			//this.Localizable = true;
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).EndInit();			
			this.ResumeLayout(false);
			this.PerformLayout();
		}
		#endregion
				
		#region ComboBox List
		
				
		private Entities.TList<Entities.ArtiklSpecifikacija> _IDSpecList;
		
		/// <summary>
		/// The ComboBox associated with the IDSpec property.
		/// </summary>
		[System.ComponentModel.Category("ComboBox BindingSources")]
		public Entities.TList<Entities.ArtiklSpecifikacija> IDSpecList
		{
			get {return _IDSpecList;}
			set 
			{
				this._IDSpecList = value;
				this.uxIDSpec.DataSource = null;
				this.uxIDSpec.DataSource = value;
			}
		}
		
		private bool _allowNewItemInIDSpecList;
		
		/// <summary>
		/// Indicates if the ComboBox associated with the IDSpec property allow user to add item.
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDSpecList
		{
			get { return _allowNewItemInIDSpecList;}
			set
			{
				this._allowNewItemInIDSpecList = value;
				this.uxIDSpec.DropDownStyle = value ? System.Windows.Forms.ComboBoxStyle.DropDown : System.Windows.Forms.ComboBoxStyle.DropDownList;
			}
		}
		
				
		private Entities.TList<Entities.Rabat> _IDRabatList;
		
		/// <summary>
		/// The ComboBox associated with the IDRabat property.
		/// </summary>
		[System.ComponentModel.Category("ComboBox BindingSources")]
		public Entities.TList<Entities.Rabat> IDRabatList
		{
			get {return _IDRabatList;}
			set 
			{
				this._IDRabatList = value;
				this.uxIDRabat.DataSource = null;
				this.uxIDRabat.DataSource = value;
			}
		}
		
		private bool _allowNewItemInIDRabatList;
		
		/// <summary>
		/// Indicates if the ComboBox associated with the IDRabat property allow user to add item.
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDRabatList
		{
			get { return _allowNewItemInIDRabatList;}
			set
			{
				this._allowNewItemInIDRabatList = value;
				this.uxIDRabat.DropDownStyle = value ? System.Windows.Forms.ComboBoxStyle.DropDown : System.Windows.Forms.ComboBoxStyle.DropDownList;
			}
		}
		
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	}
}
